<html>
<head>
<title>管理系统</title>
<meta http-equiv=Content-Type content=text/html;charset=utf-8>
<#include "../inc/commonJs.html">
<script language="JavaScript">
	var grid;
	$(function() {
		//分类管理表格  
		grid = $('#opiniongrid').datagrid({
         url:'listOpinion.do',  
         loadMsg:'数据加载中请稍后……',  
         striped: true,  
         singleSelect : true,  
         pagination: true,  
         rownumbers: true, 
         pageSize: [${syscfg.pageSize!10}],
         pageList: [${syscfg.pageList!10}],
         columns:[[  
             {field:'id',title: 'ID',align: 'center',width: '50'},  
             {field:'yourname',title: '建议人',align: 'center',width: '100'},
             {field:'topic',title: '主题',align: 'center',width: '300'},
             {field:'telephone',title: '电话',align: 'center',width: '150'},
             {field:'email',title: '电子邮箱',align: 'center',width: '200'},
             {field:'havereply',title: '处理状态',align: 'center',width: '70',
             	formatter:function(value,rowdata,index){
             			if(value==0){
             				return "<font color='red'>未回复</font>";
             			}else{
             				return "已回复";
             			}
             	}
             },
             {field:'updatetime',title: '日期',align: 'center',width: '150'},
             {field:'checked',title: '操作',align: 'center',width: '100',
             	formatter: function(value,rowdata,index){
             		var str = '';
					if(value ==0){
						str += '<a id="btnadd" class="l-btn l-btn-plain" href="javascript:void(0)"><span class="l-btn-left"><span class="l-btn-text icon-no l-btn-icon-left" onclick="shenheOpinion('+rowdata.id+','+rowdata.checked+')">审核</span></span></a>';
					}else{
						str += '<a id="btnadd" class="l-btn l-btn-plain" href="javascript:void(0)"><span class="l-btn-left"><span class="l-btn-text icon-ok l-btn-icon-left" onclick="shenheOpinion('+rowdata.id+','+rowdata.checked+')">取消</span></span></a>';
					}
					return str;
				}
             }]],
             toolbar : "#toolbar",
			onDblClickCell: function(index,field,value){
	     		editOpinion();
			}
     });
  })
  
	//工具栏修改用户
	function editOpinion() {
		var selected = $('#opiniongrid').datagrid('getSelected');
		if(!selected){
			window.top.$.messager.alert('提示',"请选择相关数据进行操作！");
			return;
		}
		var modalwindow =  window.top.modalwindow('${request.contextPath}/xadmin/added/opinionWindow.do?id='+selected.id,$('#opiniongrid'),{    
		    width:850,    
		    height:580,
		    modal:true,
		    resizable:true,
		    title:'回复建议信息',
		    buttons:[{
				text:'保存',
				iconCls:"icon-save",
				handler:function(){
					modalwindow.find('iframe').get(0).contentWindow.saveOpinion(id);
				}
			},{
				text:'关闭',
				iconCls:"icon-cancel",
				handler:function(){
					modalwindow.dialog('close');
				}
			}]   
		});
	};
	//工具栏删除建议
	function delOpinion(){
		var selected = $('#opiniongrid').datagrid('getSelected');
		if(!selected){
			window.top.$.messager.alert('提示',"请选择相关数据进行操作！");
			return;
		}
		window.top.$.messager.confirm('系统提示', '<br>&nbsp;&nbsp;&nbsp;&nbsp;你确定要删除该信息?', function(r) {
			if (r) {
				$.post("${request.contextPath}/xadmin/added/delOpinion.do", { "id": selected.id},
				   function(data){
				   	$('#opiniongrid').datagrid('reload'); 
				   	window.top.$.messager.alert('提示',data);
				   	
				});
			}
		});
	}
	function shenheOpinion(id,result){
		if(result==0){
			result =1;
		}else{
			result = 0;
		}
		$.post("${request.contextPath}/xadmin/added/shenheOpinion.do", 
			{ "id": id,"result":"checked="+result},
		   	function(data){
		   		$('#opiniongrid').datagrid('reload'); 
		   		window.top.$.messager.alert('提示',data);
		});
	}
	function restore(){
		$('#toolbar input').val('');
		$('#opiniongrid').datagrid('reload',{});
	}
	function dosearch(){
		var params = {};
		if($('#topic').val()){
			params['topic'] = $('#topic').val();
		}
		if($('#havereply').combobox('getValue')){
			params['havereply'] = $('#havereply').combobox('getValue');
		}
		$('#opiniongrid').datagrid('reload',params);
	}
</script>

</head>
<body>
	<table id="opiniongrid" data-options="fit:true,border:false"></table>
	<div id="toolbar" style="display: none;">
		<table>
			<tr >
				<td valign="center">
					主题&nbsp;:&nbsp;
					<input class="easyui-validatebox" type="text" id="topic" name="topic" maxlength="30" style="width:150px;">
					处理状态 &nbsp;:&nbsp;
					<select id="havereply" class="easyui-combobox" name="havereply" panelHeight="50" style="width:200px;">   
					    <option value="1">已回复</option>   
					    <option value="0">未回复</option>   
					</select>
				</td>
				<td valign="center" align="left">
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="dosearch();">搜索</a>
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-help',plain:true" onclick="editOpinion();">回复</a>
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="restore();">刷新</a>
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true" onclick="delOpinion()">删除</a>
				</td>
			</tr>
		</table>
	</div>
</body>
</html>